package com.zhouchao.provider;

import com.zhouchao.provider.server.RpcServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @Author: zhouchao
 * @Date: 2021/08/01 01:17
 * @Description:
 */
@SpringBootApplication
public class ServerBootstrapApplication implements CommandLineRunner {

    @Autowired
    RpcServer rpcServer;

    public static void main(String[] args) {
        SpringApplication.run(ServerBootstrapApplication.class, args);
    }

    @Override
    public void run(String... args) throws Exception {
        String port = System.getenv("port");
        new Thread(() ->
                rpcServer.startServer("127.0.0.1", Integer.parseInt(port))
        ).start();
    }
}
